<?php
/**
 * Created by PhpStorm.
 * User: Huyang
 * Date: 2016/9/20
 * Time: 13:28
 */

namespace App\Http\Requests\Api;

use App\Exceptions\ServiceException;
use App\Http\Constants\CommonExceptionConstants;
use App\Http\Repositories\Daos\IUserDao;
use Illuminate\Http\Request;

class AdminContext
{

    private $id;

    public function __construct(Request $request, IUserDao $userDao)
    {

        $user = $request->session()->get('admin_user');

        if (empty($user['id'])) {
            throw new ServiceException(CommonExceptionConstants::getKey('no_login'));
        }

        $this->setId($user['id']);

    }

    /**
     * @return mixed
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @param mixed $id
     */
    public function setId($id)
    {
        $this->id = $id;
    }

}